﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DTOs;
using Entities;

namespace giftdeliveryservice.Controllers
{
    public class HomeController : Controller
    {

        public const int PageSize = 20;


        public ActionResult Index()
        {
            DataManager manager = new DataManager();

            //manager.AddProductCategory("Cakes", "CAK");
            //manager.AddProductCategory("Gifts", "GFT");
            //manager.AddProductCategory("Ice Creams", "ICR");

            var prdCategories = manager.GetProductCategories();

            //ViewBag.Message = "Welcome to ASP.NET MVC! Kajan";

            return View(prdCategories);
        }


        public ActionResult ProductList(int categoryId, int pageNumber)
        {

            DataManager manager = new DataManager();
            var productList = manager.GetProductDetails(categoryId, pageNumber, PageSize);
            //var people = new PagedData<ProductDTO>();

            //using (var ctx = new AjaxPagingContext())
            //{
            //    people.Data = ctx.People.OrderBy(p => p.Surname).Skip(PageSize * (page - 1)).Take(PageSize).ToList();
            //    people.NumberOfPages = Convert.ToInt32(Math.Ceiling((double)ctx.People.Count() / PageSize));
            //    people.CurrentPage = page;
            //}



            return PartialView(productList);
        }

        public ActionResult index1()
        {
            return View();
        }

        public ActionResult About()
        {
            return View();
        }
    }
}
